{{define "/chat/index.shtml"}}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport"
          content="width=width-device, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>IM</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/mui/3.7.1/css/mui.min.css">
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script>
    <script src="https://cdn.bootcss.com/mui/3.7.1/js/mui.min.js"></script>
</head>
<body>
<div class="mui-card">
    <!--页眉，放置标题-->
    <div class="mui-card-header">好友列表</div>
    <!--内容区-->
    <div id="app" class="mui-card-content">
        <ul>
            <li v-for="item in friends">
                <span v-text="item.mobile" @click="chat(item.id)"></span>
            </li>
        </ul>
    </div>
    <!--页脚，放置补充信息或支持的操作-->
    <div class="mui-card-footer">功能面板kmkmm</div>
</div>
</body>
<script>

    var router = new VueRouter({
        mode: 'history',
        routes: []
    });

    var app = new Vue({
        router,
        el: '#app',
        data: {
            friends: []
        },
        mounted: function () {
            this.getFriends()
        },
        methods: {
            getFriends: function () {

                let getFriends = axios({
                    method: 'post',
                    url: '/contact/getFriends',
                    params: {
                        ownerId: this.$route.query.id
                    }
                }).then(response => {
                    let result = response.data

                    if (result.code != 0) {
                        mui.toast(result.msg)
                    } else {
                        this.friends = result.data
                    }
                }).catch(e => {
                    console.log(e.message)
                })
            },
            chat: function (dstId) {
                let url = "/chat/private.shtml?id=" + this.$route.query.id + "&token=" + this.$route.query.token + "&dstId="
                    + dstId
                location.href = url
            }
        }
    })
</script>
</html>
{{end}}